#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QTime>
#include <QtCore>
#include <QDebug>
#include <QTcpSocket>
#include <QTcpServer>
#include <QtCore/QString>



#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cerrno>
#include <cstring>
#include <string>
#include <sys/socket.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <unistd.h>
#include <arpa/inet.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <linux/input.h>


#include "csvfile.h"


#define CSVFILE_PATH "/home/root/myirmac.csv"

/*mac struct */
struct _test_mac
{
    unsigned int cmd;
    unsigned int status;
	unsigned int isrdy;
    unsigned int MacNum;
    unsigned int MacaValue_a[6];  //eth1
    unsigned int MacaValue_b[6];  //eth0
};

struct _board_mac
{
	struct _test_mac  MacData_sd;
	struct _test_mac  MacData_rv;
};

namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();

    QString m_text;

    // csvfile;
    csvfile m_mac_csvfile;
    // QString scan_mac;

private slots:
    int update_socketstatus();
    int server_new_connect();
    void socket_read_data();
    void socket_disconnect();
    int scan_check();

    int save_csvfile();
    int copy_csvfile();
    
private:
    Ui::MainWindow *ui;

    QTcpServer *m_server;
    QTcpSocket *m_socket;

    QTimer *timer_scan;
    QTimer *timer_updateui;

    int isConn_socket;
    int isConn_heart;

    int load_csvfile();
    void update_recvmac();
    void update_ui_mac();
};

#endif // MAINWINDOW_H
